Commit 458b8b6e authored by xiao-hesheng's avatar xiao-hesheng
Browse files

新增采购计划审核脚本

parent 2c65e340
......@@ -12,18 +12,21 @@ from common.common_func import commonFuc
from air_case.mdm_login.登录外网系统.登录外网系统 import login_system
from airtest.core.api import using
import sys
module = "a4_mdm3_cm"
def supply_and_marketing_apply():
pro_path=commonFuc().get_pro_path()
sys.path.append(pro_path+r'\\air_case\\a4_mdm3_cm\\a2供货关系申请_客户类型_医院_登录_企业登录.air')
using(pro_path+r'\\air_case\\a4_mdm3_cm\\a2供货关系申请_客户类型_医院_登录_企业登录.air')
pro_path = commonFuc().get_pro_path()
sys.path.append(pro_path + r'\\air_case\\a4_mdm3_cm\\a2供货关系申请_客户类型_医院_登录_企业登录.air')
using(pro_path + r'\\air_case\\a4_mdm3_cm\\a2供货关系申请_客户类型_医院_登录_企业登录.air')
from a2供货关系申请_客户类型_医院_登录_企业登录 import e_login
token,projectCode,uxid,corpId,username=e_login()
#获取医院corpId
token, projectCode, uxid, corpId, username = e_login()
# 获取医院corpId
sys.path.append(pro_path + r'\\air_case\\a4_mdm3_cm\\a1供货关系申请_客户类型_医院_登录_医院登录获取医院id.air')
using(pro_path + r'\\air_case\\a4_mdm3_cm\\a1供货关系申请_客户类型_医院_登录_医院登录获取医院id.air')
from a1供货关系申请_客户类型_医院_登录_医院登录获取医院id import h_login
h_token,h_projectCode,h_uxid,h_corpId,h_name=h_login()
h_token, h_projectCode, h_uxid, h_corpId, h_name = h_login()
"""
场景:a3供货关系申请_客户类型_医院_供销关系申请提交
用例名称:a3供货关系申请_客户类型_医院_供销关系申请提交
......@@ -31,24 +34,26 @@ def supply_and_marketing_apply():
输出:"rtn_msg": ok
"""
# module = "mdm3_cm"
#a3供货关系申请_客户类型_医院_供销关系申请提交
# a3供货关系申请_客户类型_医院_供销关系申请提交
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "submitSupplyRelation_url")
# 获取请求头信息
headers = commonFuc().get_business_data(module, "json_headers2",
commonFuc().get_business_data(module, "json_contentType"), token,
projectCode)
contactUser=commonFuc().randomString(5)
contactWay=contactUser
request_body = commonFuc().get_business_data(module, "payload",h_corpId,contactUser,contactWay)
contactUser = commonFuc().randomString(5)
contactWay = contactUser
request_body = commonFuc().get_business_data(module, "payload", h_corpId, contactUser, contactWay)
# 发送请求
result = commonFuc().http_post(url, request_body, headers)
print('result',result)
print('result', result)
# #获取接口返回数据
#
check_dict= commonFuc().get_business_data(module, "checkDict")
commonFuc().check_result(check_dict,result)
e_corpId=corpId
e_username=username
return e_corpId,h_corpId,e_username,h_name
check_dict = commonFuc().get_business_data(module, "checkDict")
commonFuc().check_result(check_dict, result)
e_corpId = corpId
e_username = username
return e_corpId, h_corpId, e_username, h_name
# supply_and_marketing_apply()
FileUtils().w_info1(supply_and_marketing_apply(),module,'供货关系申请')
\ No newline at end of file
FileUtils().w_info1(supply_and_marketing_apply(), module, '供货关系申请')
......@@ -3,29 +3,32 @@ from ruamel import yaml
from common.db.db import dbOP
import datetime
curpath = os.path.dirname(os.path.realpath(__file__))
rootPath = os.path.split(curpath)[0]
# 数据读入和写入文件
class FileUtils(object):
def w_info(self, info,keyname):
module=info[2]
def w_info(self, info, keyname):
module = info[2]
dict = {}
value = {}
value['username'] = info[0]
value['goodsname'] = info[1]
key=keyname
key = keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
w_path = rootPath + os.sep + 'data' + os.sep + module
# print(w_path)
yamlpath = os.path.join(w_path, "message")
# 写入到yaml文件
with open(yamlpath, "w", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper,allow_unicode=True)
def r_info(self, module,keyname):
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
def r_info(self, module, keyname):
w_path = rootPath + os.sep + 'data' + os.sep + module
yamlpath = os.path.join(w_path, "message")
file_value = open(yamlpath, 'r',encoding='utf-8')
file_value = open(yamlpath, 'r', encoding='utf-8')
result = yaml.load(file_value.read(), Loader=yaml.Loader)
if result is not None:
key = keyname
......@@ -53,24 +56,26 @@ class FileUtils(object):
return None
else:
return None
#供货关系信息写入文件
def w_info1(self, info,module,keyname):
module=module
# 供货关系信息写入文件
def w_info1(self, info, module, keyname):
module = module
dict = {}
value = {}
value['e_corpId'] = info[0]
value['h_corpId'] = info[1]
value['e_username'] = info[2]
value['h_name'] = info[3]
key=keyname
key = keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
w_path = rootPath + os.sep + 'data' + os.sep + module
# print(w_path)
yamlpath = os.path.join(w_path, "message")
# 写入到yaml文件
with open(yamlpath, "w", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper,allow_unicode=True)
#写入院区数据,新函数,存在已有内容,替换掉旧内容
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
# 写入院区数据,新函数,存在已有内容,替换掉旧内容
def w_info2_new(self, newinfo, module, keyname, oldinfo):
module = module
dict = {}
......@@ -95,46 +100,49 @@ class FileUtils(object):
# 写入到yaml文件
with open(yamlpath, "a", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
#写入院区数据
def w_info2(self, info,module,keyname):
module=module
# 写入院区数据
def w_info2(self, info, module, keyname):
module = module
dict = {}
value = {}
value['branch_id'] = info[0]
value['branch_name'] = info[1]
key=keyname
key = keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
w_path = rootPath + os.sep + 'data' + os.sep + module
# print(w_path)
yamlpath = os.path.join(w_path, "message")
if (self.r_info(module,keyname)!=None):
if (self.r_info(module, keyname) != None):
# 写入到yaml文件
with open(yamlpath, "w", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper,allow_unicode=True)
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
else:
# 写入到yaml文件
with open(yamlpath, "a", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
#写入公告id和公告标题
def w_info3(self, info,module,keyname):
module=module
# 写入公告id和公告标题
def w_info3(self, info, module, keyname):
module = module
dict = {}
value = {}
value['notices_id'] = info[0]
value['notices_name'] = info[1]
key=keyname
key = keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
w_path = rootPath + os.sep + 'data' + os.sep + module
# print(w_path)
yamlpath = os.path.join(w_path, "message1")
# 写入到yaml文件
with open(yamlpath, "w", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
#读取公告id和标题
def r_info3(self, module,keyname):
# 读取公告id和标题
def r_info3(self, module, keyname):
w_path = rootPath + os.sep + 'data' + os.sep + module
yamlpath = os.path.join(w_path, "message1")
file_value = open(yamlpath, 'r',encoding='utf-8')
file_value = open(yamlpath, 'r', encoding='utf-8')
result = yaml.load(file_value.read(), Loader=yaml.Loader)
if result is not None:
key = keyname
......@@ -144,21 +152,22 @@ class FileUtils(object):
return None
else:
return None
#写入科室信息
def w_info4(self, info,module,keyname,titlename):
module=module
# 写入科室信息
def w_info4(self, info, module, keyname, titlename):
module = module
dict = {}
value = {}
for i in range(len(titlename)):
value[titlename[i]] = info[i]
# value[titlename[0]] = info[0]
# value[titlename[1]] = info[1]
key=keyname
key = keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
w_path = rootPath + os.sep + 'data' + os.sep + module
# print(w_path)
yamlpath = os.path.join(w_path, "message")
if (self.r_info(module,keyname)!=None):
if (self.r_info(module, keyname) != None):
print('已有相同信息,不写入')
# 写入到yaml文件
# with open(yamlpath, "w", encoding="utf-8") as f:
......@@ -167,58 +176,61 @@ class FileUtils(object):
# 写入到yaml文件
with open(yamlpath, "a", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
#写入医院信息
def w_info5(self, info,module,keyname,titlename):
module=module
# 写入医院信息
def w_info5(self, info, module, keyname, titlename):
module = module
dict = {}
value = {}
for i in range(len(titlename)):
value[titlename[i]] = info[i]
# value[titlename[0]] = info[0]
# value[titlename[1]] = info[1]
key=keyname
key = keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
w_path = rootPath + os.sep + 'data' + os.sep + module
# print(w_path)
yamlpath = os.path.join(w_path, "message")
if (self.r_info(module,keyname)!=None):
if (self.r_info(module, keyname) != None):
print('已有相同信息,覆盖写入')
# 写入到yaml文件
with open(yamlpath, "w", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper,allow_unicode=True)
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
else:
# 写入到yaml文件
with open(yamlpath, "a", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
#写入产品审核信息
def w_info6(self, info,module,keyname,titlename,message_no):
module=module
# 写入产品审核信息
def w_info6(self, info, module, keyname, titlename, message_no):
module = module
dict = {}
value = {}
for i in range(len(titlename)):
value[titlename[i]] = info[i]
# value[titlename[0]] = info[0]
# value[titlename[1]] = info[1]
key=keyname
key = keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
w_path = rootPath + os.sep + 'data' + os.sep + module
# print(w_path)
yamlpath = os.path.join(w_path, message_no)
if (self.r_info2(module,keyname)!=None):
if (self.r_info2(module, keyname) != None):
print('已有相同信息,覆盖写入')
# 写入到yaml文件
with open(yamlpath, "w", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper,allow_unicode=True)
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
else:
# 写入到yaml文件
with open(yamlpath, "a", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
def r_info6(self, module,keyname,message_no):
def r_info6(self, module, keyname, message_no):
w_path = rootPath + os.sep + 'data' + os.sep + module
yamlpath = os.path.join(w_path, message_no)
file_value = open(yamlpath, 'r',encoding='utf-8')
file_value = open(yamlpath, 'r', encoding='utf-8')
result = yaml.load(file_value.read(), Loader=yaml.Loader)
if result is not None:
key = keyname
......@@ -228,20 +240,21 @@ class FileUtils(object):
return None
else:
return None
def w_info7(self, info,module,keyname,titlename,message_no):
module=module
def w_info7(self, info, module, keyname, titlename, message_no):
module = module
dict = {}
value = {}
for i in range(len(titlename)):
value[titlename[i]] = info[i]
# value[titlename[0]] = info[0]
# value[titlename[1]] = info[1]
key=keyname
key = keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
w_path = rootPath + os.sep + 'data' + os.sep + module
# print(w_path)
yamlpath = os.path.join(w_path, message_no)
if (self.r_info2(module,keyname)!=None):
if (self.r_info2(module, keyname) != None):
print('已有相同信息,不写入')
# 写入到yaml文件
# with open(yamlpath, "w", encoding="utf-8") as f:
......@@ -251,31 +264,32 @@ class FileUtils(object):
# 写入到yaml文件
with open(yamlpath, "a", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
def w_info8(self, info,module,keyname,titlename,message_no):
module=module
def w_info8(self, info, module, keyname, titlename, message_no):
module = module
dict = {}
value = {}
for i in range(len(titlename)):
value[titlename[i]] = info[i]
# value[titlename[0]] = info[0]
# value[titlename[1]] = info[1]
key=keyname
key = keyname
dict[key] = value
w_path=rootPath+os.sep+'data'+os.sep+module
w_path = rootPath + os.sep + 'data' + os.sep + module
# print(w_path)
yamlpath = os.path.join(w_path, message_no)
if (self.r_info8(module,keyname,message_no)!=None):
if (self.r_info8(module, keyname, message_no) != None):
print('已有相同信息,覆盖写入')
# 写入到yaml文件
with open(yamlpath, "w", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper,allow_unicode=True)
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
else:
# 写入到yaml文件
with open(yamlpath, "a", encoding="utf-8") as f:
yaml.dump(dict, f, Dumper=yaml.RoundTripDumper, allow_unicode=True)
def r_info8(self, module, keyname,message_no):
def r_info8(self, module, keyname, message_no):
w_path = rootPath + os.sep + 'data' + os.sep + module
yamlpath = os.path.join(w_path, message_no)
try:
......@@ -292,19 +306,10 @@ class FileUtils(object):
return None
else:
return None
if __name__ == '__main__':
# info=("aaaa","bbbbbb","mdm3-pim")
# FileUtils().w_info(info,"产品新增")
aa=FileUtils().r_info("mdm3-pim","产品新增")
aa = FileUtils().r_info("mdm3-pim", "产品新增")
print(aa['username'])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment