Commit a7dfc010 authored by xiao-hesheng's avatar xiao-hesheng
Browse files

数据库验证流程十一脚本编写

parent 1535bf5a
...@@ -6,7 +6,8 @@ from air_case.b1_herp3_login.登录内网系统.登录内网系统 import login_ ...@@ -6,7 +6,8 @@ from air_case.b1_herp3_login.登录内网系统.登录内网系统 import login_
from air_case.public1.public1.public1 import * from air_case.public1.public1.public1 import *
from common.db.sql.sql_del_branch_info import delData from common.db.sql.sql_del_branch_info import delData
from common.db.sql.sql_tools import get_create_time, check_mcms_dept_buy_car_sql, get_dept_buy_id, \ from common.db.sql.sql_tools import get_create_time, check_mcms_dept_buy_car_sql, get_dept_buy_id, \
check_mcms_dept_buy_sql, get_mdm_goods_code, get_expdt_date, check_mcms_pur_plan_sql, check_in_check_mcms_purchase check_mcms_dept_buy_sql, get_mdm_goods_code, get_expdt_date, check_mcms_pur_plan_sql, check_in_check_mcms_purchase, \
get_expdt_date1, process_date
from common.db.sql.sql_tools_out import check_out_check_mcms_purchase from common.db.sql.sql_tools_out import check_out_check_mcms_purchase
from common.fileUtls import FileUtils from common.fileUtls import FileUtils
...@@ -1120,17 +1121,24 @@ def check_hdi_distr(type=16): ...@@ -1120,17 +1121,24 @@ def check_hdi_distr(type=16):
"select id from mcms_purchase where branch_id = '%s' and bill_mode='%s' order by create_time desc LIMIT 1;" % ( "select id from mcms_purchase where branch_id = '%s' and bill_mode='%s' order by create_time desc LIMIT 1;" % (
branch_id, type)) branch_id, type))
pur_bill_id = source_id pur_bill_id = source_id
rec_user = '自动化测试w&vqF' info = FileUtils().r_info8('b2_herp3_bs', "用户名信息", 'message3')
rec_user = info['username1']
sql = "select id from spd3_herp_test2.mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc LIMIT 1;" % ( sql = "select id from spd3_herp_test2.mcms_dept_buy where branch_id='%s' and bill_mode='%s' order by create_time desc LIMIT 1;" % (
branch_id, type) branch_id, type)
print(sql) print(sql)
buyBillId = process_tuple(get_dept_buy_id(sql)) buyBillId = process_tuple(get_dept_buy_id(sql))
purBillDate = get_expdt_date( bill_relation_json=get_id("select bill_relation_json from hdi_distr a where id = '%s' and bill_mode='%s' order by create_time desc LIMIT 1;" % (
"select create_time from mcms_purchase where branch_id = '%s' and bill_mode='%s' order by create_time desc LIMIT 1;" % ( distr_main_key, type))
branch_id, type)) print(bill_relation_json)
purBillDate=reGetString(bill_relation_json,r'purBillDate":"',r'""distrBillId')
# purBillDate = get_expdt_date(
# "select create_time from mcms_purchase where branch_id = '%s' and bill_mode='%s' order by create_time desc LIMIT 1;" % (
# branch_id, type))
# process_date(purBillDate)
distrBillId = distr_main_key distrBillId = distr_main_key
distrOrderNo = distr_order_no distrOrderNo = distr_order_no
distrUser = get_login_user_uxid() distrUser = get_login_user_uxid2()
create_user = distrUser create_user = distrUser
create_user_name = FileUtils().r_info8('b5_spd3_core_business_flow', '供货关系申请2', 'message')["e_username"] create_user_name = FileUtils().r_info8('b5_spd3_core_business_flow', '供货关系申请2', 'message')["e_username"]
create_time = get_create_time( create_time = get_create_time(
...@@ -1146,6 +1154,7 @@ def check_hdi_distr(type=16): ...@@ -1146,6 +1154,7 @@ def check_hdi_distr(type=16):
get_id( get_id(
"select pid from spd3_herp_test2.mcms_pur_plan_detail where hos_goods_id='%s' order by create_time desc LIMIT 1;" % ( "select pid from spd3_herp_test2.mcms_pur_plan_detail where hos_goods_id='%s' order by create_time desc LIMIT 1;" % (
hos_goods_id))) hos_goods_id)))
planOrderNo = process_tuple( planOrderNo = process_tuple(
get_id( get_id(
"select order_no from spd3_herp_test2.mcms_pur_plan_detail where hos_goods_id='%s' order by create_time desc LIMIT 1;" % ( "select order_no from spd3_herp_test2.mcms_pur_plan_detail where hos_goods_id='%s' order by create_time desc LIMIT 1;" % (
...@@ -1170,11 +1179,11 @@ def check_hdi_distr(type=16): ...@@ -1170,11 +1179,11 @@ def check_hdi_distr(type=16):
pur_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1'] pur_dept_id = FileUtils().r_info8("b2_herp3_bs", "所有科室id", 'message6')['deptid1']
pur_dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid1'] pur_dept_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid1']
rec_org_id = process_tuple( rec_org_id = process_tuple(
get_id("select id from spd3_herp_test2.sys_org where branch_id='%s' and ename='%s';" % (branch_id, pur_dept_name))) get_id("select id from spd3_herp_test2.sys_org where branch_id='%s' and ename='%s';" % (branch_id, FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2'])))
rec_org_name = pur_dept_name rec_org_name = FileUtils().r_info8("b2_herp3_bs", "所有科室name", 'message6')['deptid2']
last_modified=create_time last_modified=create_time
import pdb # import pdb
pdb.set_trace() # pdb.set_trace()
expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check', expected = commonFuc().get_business_data('b6_spd3_core_business_flow_database_check',
'hdi_distr', distr_main_key, distr_order_no, hos_id, get_hosname(), 'hdi_distr', distr_main_key, distr_order_no, hos_id, get_hosname(),
get_branch_id(), source_id, pur_bill_id, prov_id, prov_name, get_branch_id(), source_id, pur_bill_id, prov_id, prov_name,
......
...@@ -3449,4 +3449,19 @@ def get_login_user_uxid(): ...@@ -3449,4 +3449,19 @@ def get_login_user_uxid():
# print(username, password,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa') # print(username, password,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
# 获取token和projectCode # 获取token和projectCode
token1, projectCode1, uxid1, corpId1, info1 = login_system(username, password).get_token() token1, projectCode1, uxid1, corpId1, info1 = login_system(username, password).get_token()
return uxid1
def get_login_user_uxid2():
module = "b5_spd3_core_business_flow"
# 登录获取用户id等信息,使用创建的用户登录===========开始
info = FileUtils().r_info8(module, "供货关系申请2", 'message')
print(info)
username1 = info['e_username']
username = username1
## print('医院名称',username)
password = commonFuc().get_business_data(module, "password")
# print(username, password,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
# 获取token和projectCode
token1, projectCode1, uxid1, corpId1, info1 = login(username, password,1)
return uxid1 return uxid1
\ No newline at end of file
...@@ -144,6 +144,11 @@ def get_expdt_date(sql): ...@@ -144,6 +144,11 @@ def get_expdt_date(sql):
# print(new_str1) # print(new_str1)
cursor.close() cursor.close()
return new_str1 return new_str1
def get_expdt_date1(sql):
db, cursor = get_sql_conn()
cursor.execute(sql)
results = cursor.fetchone()
return results
def get_id(sql): def get_id(sql):
db, cursor = get_sql_conn() db, cursor = get_sql_conn()
cursor.execute(sql) cursor.execute(sql)
...@@ -188,5 +193,33 @@ def check_in_check_mcms_purchase(sql): ...@@ -188,5 +193,33 @@ def check_in_check_mcms_purchase(sql):
# print(new_str1) # print(new_str1)
cursor.close() cursor.close()
return new_str1 return new_str1
def process_date(str1):
# str1 = "datetime.datetime(2024, 9, 17, 15, 32, 58)"
str2 = str1.replace('datetime.datetime(', "")
str3 = str2.replace(')', "")
result = str3.split(",")
result.pop(3)
result.pop(4)
result.pop(3)
print(result)
b = [int(x) for x in result]
print(type(b), b)
date_list = b
#
from datetime import datetime
# # 假设我们有一个列表,包含年、月、日
# date_list = [2023, 3, 14]
# print(type(date_list),date_list)
#
# # 使用列表元素构造字符串
date_string = '-'.join(map(str, date_list))
#
# # 使用datetime.strptime将字符串转换为日期
date = datetime.strptime(date_string, '%Y-%m-%d').date()
#
print(date) # 输出: 2023-03-14
return date
# hos_goods_id = 'h034700004220' # hos_goods_id = 'h034700004220'
# main2(hos_goods_id) # main2(hos_goods_id)
\ No newline at end of file
...@@ -113,7 +113,11 @@ def process_tuple(tuple1): ...@@ -113,7 +113,11 @@ def process_tuple(tuple1):
new_str1 = new_str1.replace(',', '') new_str1 = new_str1.replace(',', '')
new_str1 = new_str1.replace("'", '') new_str1 = new_str1.replace("'", '')
return new_str1 return new_str1
def get_expdt_date1(sql):
db, cursor = get_sql_conn()
cursor.execute(sql)
results = cursor.fetchone()
return results
def get_mdm_goods_code(sql): def get_mdm_goods_code(sql):
db, cursor = get_sql_conn() db, cursor = get_sql_conn()
cursor.execute(sql) cursor.execute(sql)
......
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