Commit aea1299a authored by libin's avatar libin
Browse files

自动化初始数据

parent 8f4d2b8d
#-*- coding:utf-8 -*-
from src.common import mysql_client
from src.datalib import test_data
def init():
sql_obj = mysql_client.MySQLClient(test_data.MYSQL_IP, test_data.MYSQL_PORT, test_data.MYSQL_NAME, \
test_data.MYSQL_PASSWD, test_data.MYSQL_DB_RESERVESTATION)
sql_obj.connectdb()
select_domain_sql = "SELECT id,domainUrl FROM domain WHERE domainName='%s';"%(test_data.COMPANY_NAME)
sql_obj.executeSQL(select_domain_sql)
test_data.COMPANY_ID = sql_obj.result[0][0]
test_data.COMPANY_URL = sql_obj.result[0][1]
# print(test_data.COMPANY_ID,test_data.COMPANY_URL)
#园区
select_park_sql = "SELECT id,parkName,amTime,pmTime FROM park WHERE domainId=%s"%(test_data.COMPANY_ID)
sql_obj.executeSQL(select_park_sql)
test_data.PRE_PARK_ID = sql_obj.result[0][0]
test_data.PRE_PARK_NAME = sql_obj.result[0][1]
test_data.PRE_MORNING_START_TIME = sql_obj.result[0][2][:5]
test_data.PRE_MORNING_END_TIME = sql_obj.result[0][2][6:]
test_data.PRE_AFTERNOON_START_TIME = sql_obj.result[0][3][:5]
test_data.PRE_AFTERNOON_END_TIME = sql_obj.result[0][3][6:]
# print(test_data.PRE_PARK_ID,test_data.PRE_PARK_NAME,test_data.PRE_MORNING_START_TIME,test_data.PRE_MORNING_END_TIME,
# test_data.PRE_AFTERNOON_START_TIME,test_data.PRE_AFTERNOON_END_TIME)
#楼宇
select_build_sql = "SELECT id,buildingToken,officeBuildingName FROM officebuilding WHERE domainId=%s"%(test_data.COMPANY_ID)
sql_obj.executeSQL(select_build_sql)
test_data.PRE_BUILD_ID = sql_obj.result[0][0]
test_data.PRE_BUILD_BUILDTOKEN = sql_obj.result[0][1]
test_data.PRE_BUILD_NAME = sql_obj.result[0][2]
# print(test_data.PRE_BUILD_ID,test_data.PRE_BUILD_BUILDTOKEN,test_data.PRE_BUILD_NAME)
#楼层
select_floor_sql = "SELECT id,floorNum FROM floor WHERE domainId=%s"%(test_data.COMPANY_ID)
sql_obj.executeSQL(select_floor_sql)
test_data.PRE_FLOOR_ID = sql_obj.result[0][0]
test_data.PRE_FLOOR_NAME = sql_obj.result[0][1]
# print(test_data.PRE_FLOOR_ID,test_data.PRE_FLOOR_NAME)
#区域
select_area_sql = "SELECT id,floorareaNum FROM floorarea WHERE domainId=%s"%(test_data.COMPANY_ID)
sql_obj.executeSQL(select_area_sql)
test_data.PRE_AREA_ID = sql_obj.result[0][0]
test_data.PRE_AREA_NAME = sql_obj.result[0][1]
# print(test_data.PRE_AREA_ID,test_data.PRE_AREA_NAME)
#部门
select_department_sql = "SELECT id,orgFatherId,orgName FROM organization WHERE domainId=%s AND orgName!='企业通讯录'"%(test_data.COMPANY_ID)
sql_obj.executeSQL(select_department_sql)
test_data.PRE_DEPARTMENT_ID = sql_obj.result[0][0]
test_data.PRE_DEPARTMENT_FATHER_ID = sql_obj.result[0][1]
test_data.PRE_DEPARTMENT_NAME = sql_obj.result[0][2]
print(test_data.PRE_DEPARTMENT_ID,test_data.PRE_DEPARTMENT_FATHER_ID,test_data.PRE_DEPARTMENT_NAME)
#用户
select_user_sql = "SELECT id,employeeName,employeeId,attendanceCard,email FROM userinfo WHERE domainId=%s"%(test_data.COMPANY_ID)
sql_obj.executeSQL(select_user_sql)
test_data.PRE_USER_ID = sql_obj.result[0][0]
test_data.PRE_USER_NAME = sql_obj.result[0][1]
test_data.PRE_USER_JOB_NUMBER = sql_obj.result[0][2]
test_data.PRE_USER_CARD_NUMBER = sql_obj.result[0][3]
test_data.PRE_USER_EMAIL = sql_obj.result[0][4]
# print(test_data.PRE_USER_ID,test_data.PRE_USER_NAME,test_data.PRE_USER_JOB_NUMBER,test_data.PRE_USER_CARD_NUMBER,test_data.PRE_USER_EMAIL)
#角色
select_common_role_sql = "SELECT id FROM role WHERE domainId=%s AND roleName='普通用户'"%(test_data.COMPANY_ID)
sql_obj.executeSQL(select_common_role_sql)
test_data.COMMON_USER_ROLE_ID = sql_obj.result[0][0]
select_special_role_sql = "SELECT id FROM role WHERE domainId=%s AND roleName='特殊预约用户'" % (test_data.COMPANY_ID)
sql_obj.executeSQL(select_special_role_sql)
test_data.SPECIAL_USER_ROLE_ID = sql_obj.result[0][0]
# print(test_data.COMMON_USER_ROLE_ID,test_data.SPECIAL_USER_ROLE_ID)
#工位
selec_fix_station_sql = "SELECT id,stationNum FROM mobilestation WHERE domainId=%s AND stationType=2"%(test_data.COMPANY_ID)
sql_obj.executeSQL(selec_fix_station_sql)
test_data.PRE_FIXED_STATION_ID = sql_obj.result[0][0]
test_data.PRE_FIXED_STATION_NAME = sql_obj.result[0][1]
selec_mobile_station_sql = "SELECT id,stationNum FROM mobilestation WHERE domainId=%s AND stationType=1" %(test_data.COMPANY_ID)
sql_obj.executeSQL(selec_mobile_station_sql)
test_data.PRE_MOBILE_STATION_ID = sql_obj.result[0][0]
test_data.PRE_MOBILE_STATION_NAME = sql_obj.result[0][1]
# print(test_data.PRE_FIXED_STATION_ID,test_data.PRE_FIXED_STATION_NAME,test_data.PRE_MOBILE_STATION_ID,
# test_data.PRE_MOBILE_STATION_NAME)
sql_obj.close_connect()
\ No newline at end of file
Markdown is supported
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